﻿namespace LargeFilesSample
{
    public static class AppSettingsJson
    {
        public static string? ApplicationExeDirectory()
        {
            var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var appRoot = Path.GetDirectoryName(location);
            return appRoot;
        }
        public static IConfigurationRoot GetAppSettings()
        {
            string? applicationExeDirectory = ApplicationExeDirectory();
            if (null == applicationExeDirectory)
            {
                // Error: Cannot determine app exe directory
                applicationExeDirectory = ".";
            }
            var builder = new ConfigurationBuilder().SetBasePath(applicationExeDirectory).AddJsonFile("appsettings.json");
            return builder.Build();
        }
    }
}
